import Cookies from 'js-cookie'

import store from '@store'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function changeRoles(router) {
  store.state.permission.routers = null
  store.state.tagsView.visitedViews = []
  const pageName = localStorage.getItem('默认页')
  const time = new Date().valueOf()
  router.push({ name: pageName, query: { a: time }})
}
